'connect to database server
If (0 <> vCompany.Connect()) Then
MsgBox "Failed to connect"
Exit Sub
End If
Dim nErr As Long
Dim errMsg As String
'Set the object's properties
Dim vPay As SAPbobsCOM.Payments
Set vPay = vCompany.GetBusinessObject(oIncomingPayments)
vPay.Address = ""
vPay.ApplyVAT = 1
vPay.CardCode = "10000"
vPay.CardName = "this is not a card"
vPay.CashAccount = "288000"
vPay.CashSum = 620
vPay.CheckAccount = "280001"
vPay.ContactPersonCode = 0
vPay.DocCurrency = "Eur"
vPay.DocDate = Now
vPay.DocRate = 0
vPay.DocTypte = 1
vPay.HandWritten = 0
vPay.JournalRemarks = "Jrms"
vPay.LocalCurrency = tYES
vPay.Printed = 0
vPay.Reference1 = 15
vPay.Series = 0
vPay.SplitTransaction = 0
vPay.TaxDate = Now
vPay.TransferSum = 0
vPay.AccountPayments.AccountCode = "10000"
vPay.AccountPayments.AccountName = "Acc name"
vPay.AccountPayments.LineNum = 0
vPay.AccountPayments.SumPaid = 300
vPay.AccountPayments.VatGroup = "A4"
Call vPay.AccountPayments.Add
Call vPay.AccountPayments.SetCurentLine(1)
vPay.AccountPayments.AccountCode = "10100"
vPay.AccountPayments.AccountName = "Acc name"
vPay.AccountPayments.LineNum = 1
vPay.AccountPayments.SumPaid = 320
vPay.AccountPayments.VatGroup = "A9"
If (vPay.Add() <> 0) Then
MsgBox ("Failed to add a payment")
End If
'Check Error
Call vCompany.GetLastError(nErr, errMsg)
If (0 <> nErr) Then
MsgBox ("Found error:" + Str(nErr) + "," + errMsg)
Else
MsgBox ("Succeed in payment.add")
End If
'disconnect the company object, and release resource
Call vCompany.Disconnect
Set vCompany = Nothing
Exit Sub
ErrorHandler:
MsgBox ("Exception:" + Err.Description)
End Sub